<template>

    <section class="loginWarpBg choiceBox">
      <div class="loginBg"></div>
      <div class="loginWarp">
        <span @click="goBack" class="goBack"><span></span></span>
        <p class="title">
          <img src="/static/images/title01.png">
        </p>

        <div class="info">
          
          <p class="choiceTitle">请选择您的性别</p>

          <div class="list">
            <div @click="goIndex(1)" class="left">
              <span></span>
              <p>女</p>
            </div>
            <div @click="goIndex(2)" class="right">
              <span></span>
              <p>男</p>
            </div>
          </div>

        </div>
      </div>

    </section>
</template>
<script>
import axios from 'axios'
import {Put,Get} from '@/config/api.js'
export default {
  name: 'hello',
  data() {
    return {
      name: '',
      password: '',
    }
  },
  mounted(){
    let h1=$(window).height()
    $('.loginBg,.loginWarpBg').css("height", h1)
  },
  methods: {
    //选择用户性别
    async goIndex(val){
      if(this.$store.state.login==true){
          let data={
            "gender":val
          }
          await Put('/user/me',this.$store.state.token,data).then((res)=>{
            console.log(res)
          })
      }
      let gender
      if(val==1){
        gender=2
      }else{
        gender=1
      }
      this.$store.dispatch("gender",gender);
      this.$router.push({ path: '/index'})
    },
    goBack(){
      this.$router.go(-1)
    }
  }
}

</script>
